<form action="{:sysuri()}" method="post" class="layui-form layui-card" lay-filter="pull_order_form" id="pull_order_form">

    <div class="layui-card-body">

        {if !empty($account_show) }
        <div class="layui-form-item">
            <label class="layui-form-label label-required-next">{:lang("公司")}:</label>
            <div class="layui-input-block">
                <select name="account_id" class="layui-select" lay-verify="required">
                    <option value="">请选择</option>
                    {if !empty($account_arr) }
                    {foreach $account_arr as $account_id => $account_name }
                    <option value="{$account_id|default=''}" >{$account_name|default=''}</option>
                    {/foreach}
                    {/if}
                </select>
            </div>
        </div>
        {/if}

        <div class="layui-form-item">
            <label class="layui-form-label label-required-next">{:Lang("平台")}:</label>
            <div class="layui-input-block">
                <select name="platform_id" lay-search class="layui-select" lay-filter="platform" lay-verify="required">
                    <option value="">请选择</option>
                    {foreach $platform_list as $key => $name}
                    <option value="{$key}" >{$name|default=''}</option>
                    {/foreach}
                </select>

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:Lang("店铺")}:</label>
            <div class="layui-input-block">
                <div id="xm-select-shop_ids"> </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item text-center">
        {if empty($account_show) }
        <input type="hidden" name="account_id" value="{$shop_account|default=0}">
        {/if}
        <button type="button" class="layui-btn" lay-submit lay-filter="pull_btn">{:lang('同步')}</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="{:lang('确定要取消吗')}?" data-close>{:lang('取消')}</button>
    </div>
</form>
<script>
    layui.use(['form', 'xmSelect'], function(){
        let xmSelectletObject = {
            el: '#xm-select-shop_ids',
            filterable: true,
            autoRow: true,
            toolbar: {
                show: true,
            },
            theme: {
                color: '#1cbbb4',
            },
            prop: {
                name: 'name',
                value: 'id',
            },
            data: [],
            name: 'shop_id',
        }

        let xmSelectlet = xmSelect.render(xmSelectletObject)
        let form = layui.form;
        // 指向元素为 `<select lay-filter="test"></select>` 的选择事件
        form.on('select(platform)', function(data){
            let form_data = form.val('pull_order_form');
            httpRequest('{:sysuri("common/ajax/getShopList")}', form_data, 'post', function(info, ret_data) {
                let shop_data = ret_data;
                xmSelectlet.update({
                    data: shop_data,
                })
            })
        });
        form.on('submit(pull_btn)', function(data){
            let form_data = data.field;
            httpRequest('{:sysuri()}', form_data, 'post', function(info, ret_data) {
                $.msg.success(info, 3, function () {
                    $.msg.closeThisModal('#pull_order_form')
                });
            })
            return false
        })
    })
</script>